package com.qfedu.edu.objecthandler;

import com.baomidou.mybatisplus.core.handlers.MetaObjectHandler;
import org.apache.ibatis.reflection.MetaObject;
import org.springframework.stereotype.Component;

import java.util.Date;

/**
 * @author xiaobobo
 * @title: MyMetaObjectHandler
 * @projectName CD-Java-FY-2401-Springboot-Parent
 * @description: TODO
 * @date 2024/9/11  10:49
 */
@Component
public class MyMetaObjectHandler implements MetaObjectHandler {

    @Override
    public void insertFill(MetaObject metaObject) {
       //这里实际上就是告诉他填充的值具体是什么
       this.setFieldValByName("createTime",new Date(),metaObject);
       this.setFieldValByName("updateTime",new Date(),metaObject);
    }

    @Override
    public void updateFill(MetaObject metaObject) {
     this.setFieldValByName("updateTime",new Date(),metaObject);
    }
}
